package java6681.lesson08;

import java.util.Scanner;

public class Logon6681 {
    public static void main(String[] args) {
        //已知用户名和密码，定义两个字符表示即可
        String userName = "zcxy";

        String password = "java";

//        循环实现多次机会，这里的次数明确，采用for循环实现,并在登录成功的时候，使用break结束循环。
        for (int i = 0; i < 3; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入用户名");
            String name = scanner.nextLine();
            name = name.toUpperCase();

            System.out.println("请输入密码");
            String pwd = scanner.nextLine();
            if (name.equals(userName) || name.equalsIgnoreCase(userName) && pwd.equals(password)) {
                System.out.println("登录成功");
                break;
            } else {
                if (2 - i == 0) {
                    System.out.println("账户锁定");
                } else {
                    System.out.println("登录失败" + (2 - i) + "次");
                }
            }
        }
    }
}
